package com.itheima.filedemo;

import java.io.File;
import java.io.IOException;

public class FileDemo3 {
    public static void main(String[] args) {
//        method1();
//         method2();
//        method3();
//        method4();
    }

    private static void method4() {
        // 可以创建单级和多级文件夹，只能创建文件夹
        File file = new File("D:\\IdeaProjects\\JavaStudyProject\\FileModule\\itheima\\aaa.txt");
        boolean result = file.mkdirs();
        System.out.println(result);
    }

    private static void method3() {
        // 4. 只能创建单级文件夹
        File file = new File("D:\\IdeaProjects\\JavaStudyProject\\FileModule\\itheima\\aaa.txt");
        boolean result = file.mkdir();
        System.out.println(result);
    }

    private static void method2() throws IOException {
        // 3.只能创建文件
        File file = new File("D:\\IdeaProjects\\JavaStudyProject\\FileModule\\itheima\\aaa");
        boolean result = file.createNewFile();
        System.out.println(result);
    }

    private static void method1() throws IOException {
        File file = new File("D:\\IdeaProjects\\JavaStudyProject\\FileModule\\itheima\\a.txt");
        // 1. 如果文件存在，创建失败，返回 false
        // 2. 如果文件不存在，创建成功，返回 true
        boolean result = file.createNewFile();
        System.out.println(result);
    }
}
